/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.trace;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "trace_obj_info")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraceObjInfo.findAll", query = "SELECT t FROM TraceObjInfo t"),
    @NamedQuery(name = "TraceObjInfo.findBySid", query = "SELECT t FROM TraceObjInfo t WHERE t.sid = :sid"),
    @NamedQuery(name = "TraceObjInfo.findByTraceType", query = "SELECT t FROM TraceObjInfo t WHERE t.traceType = :traceType"),
    @NamedQuery(name = "TraceObjInfo.findByObjID", query = "SELECT t FROM TraceObjInfo t WHERE t.objID = :objID"),
    @NamedQuery(name = "TraceObjInfo.findByRegionID", query = "SELECT t FROM TraceObjInfo t WHERE t.regionID = :regionID"),
    @NamedQuery(name = "TraceObjInfo.findByObj", query = "SELECT t FROM TraceObjInfo t WHERE t.obj = :obj"),
    @NamedQuery(name = "TraceObjInfo.findByMarketCode", query = "SELECT t FROM TraceObjInfo t WHERE t.marketCode = :marketCode"),
    @NamedQuery(name = "TraceObjInfo.findByClassCode", query = "SELECT t FROM TraceObjInfo t WHERE t.classCode = :classCode"),
    @NamedQuery(name = "TraceObjInfo.findByName", query = "SELECT t FROM TraceObjInfo t WHERE t.name = :name"),
    @NamedQuery(name = "TraceObjInfo.findByEName", query = "SELECT t FROM TraceObjInfo t WHERE t.eName = :eName"),
    @NamedQuery(name = "TraceObjInfo.findByLongName", query = "SELECT t FROM TraceObjInfo t WHERE t.longName = :longName"),
    @NamedQuery(name = "TraceObjInfo.findByListingDate", query = "SELECT t FROM TraceObjInfo t WHERE t.listingDate = :listingDate"),
    @NamedQuery(name = "TraceObjInfo.findByFaceValue", query = "SELECT t FROM TraceObjInfo t WHERE t.faceValue = :faceValue"),
    @NamedQuery(name = "TraceObjInfo.findByTradeUnit", query = "SELECT t FROM TraceObjInfo t WHERE t.tradeUnit = :tradeUnit"),
    @NamedQuery(name = "TraceObjInfo.findByCurrency", query = "SELECT t FROM TraceObjInfo t WHERE t.currency = :currency"),
    @NamedQuery(name = "TraceObjInfo.findByContractSize", query = "SELECT t FROM TraceObjInfo t WHERE t.contractSize = :contractSize"),
    @NamedQuery(name = "TraceObjInfo.findByTradeType", query = "SELECT t FROM TraceObjInfo t WHERE t.tradeType = :tradeType"),
    @NamedQuery(name = "TraceObjInfo.findByClearType", query = "SELECT t FROM TraceObjInfo t WHERE t.clearType = :clearType"),
    @NamedQuery(name = "TraceObjInfo.findByContractMonth", query = "SELECT t FROM TraceObjInfo t WHERE t.contractMonth = :contractMonth"),
    @NamedQuery(name = "TraceObjInfo.findByExpirationDate", query = "SELECT t FROM TraceObjInfo t WHERE t.expirationDate = :expirationDate"),
    @NamedQuery(name = "TraceObjInfo.findByUnderlyingCode", query = "SELECT t FROM TraceObjInfo t WHERE t.underlyingCode = :underlyingCode"),
    @NamedQuery(name = "TraceObjInfo.findByUnderlyingobj", query = "SELECT t FROM TraceObjInfo t WHERE t.underlyingobj = :underlyingobj"),
    @NamedQuery(name = "TraceObjInfo.findByFirst", query = "SELECT t FROM TraceObjInfo t WHERE t.first = :first"),
    @NamedQuery(name = "TraceObjInfo.findBySecend", query = "SELECT t FROM TraceObjInfo t WHERE t.secend = :secend"),
    @NamedQuery(name = "TraceObjInfo.findByThird", query = "SELECT t FROM TraceObjInfo t WHERE t.third = :third"),
    @NamedQuery(name = "TraceObjInfo.findByPutCall", query = "SELECT t FROM TraceObjInfo t WHERE t.putCall = :putCall"),
    @NamedQuery(name = "TraceObjInfo.findByStrikePrice", query = "SELECT t FROM TraceObjInfo t WHERE t.strikePrice = :strikePrice"),
    @NamedQuery(name = "TraceObjInfo.findByOptionRate", query = "SELECT t FROM TraceObjInfo t WHERE t.optionRate = :optionRate"),
    @NamedQuery(name = "TraceObjInfo.findByOwnUserID", query = "SELECT t FROM TraceObjInfo t WHERE t.ownUserID = :ownUserID"),
    @NamedQuery(name = "TraceObjInfo.findByAlterUserID", query = "SELECT t FROM TraceObjInfo t WHERE t.alterUserID = :alterUserID"),
    @NamedQuery(name = "TraceObjInfo.findByCreateTime", query = "SELECT t FROM TraceObjInfo t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TraceObjInfo.findByTimeStamp", query = "SELECT t FROM TraceObjInfo t WHERE t.timeStamp = :timeStamp")})
public class TraceObjInfo implements Serializable {
	public static byte[] EnCode(TraceObjInfo msg) throws IOException {
		Codec<TraceObjInfo> Lcode = ProtobufProxy.create(TraceObjInfo.class);
		return Lcode.encode(msg);
	}
	public static TraceObjInfo DeCode(byte[] data) throws IOException {
	Codec<TraceObjInfo> Lcode = ProtobufProxy.create(TraceObjInfo.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sid")
    @Protobuf
	private Integer sid;
    @Basic(optional = false)
    @Column(name = "TraceType")
    @Protobuf
	private String traceType;
    @Basic(optional = false)
    @Column(name = "ObjID")
    @Protobuf
	private String objID;
    @Basic(optional = false)
    @Column(name = "RegionID")
    @Protobuf
	private String regionID;
    @Basic(optional = false)
    @Column(name = "Obj")
    @Protobuf
	private String obj;
    @Basic(optional = false)
    @Column(name = "MarketCode")
    @Protobuf
	private String marketCode;
    @Basic(optional = false)
    @Column(name = "ClassCode")
    @Protobuf
	private String classCode;
    @Basic(optional = false)
    @Column(name = "Name")
    private String name;
	@Protobuf
	private byte[] nameBit;
    @Basic(optional = false)
    @Column(name = "EName")
    @Protobuf
	private String eName;
    @Column(name = "LongName")
    @Protobuf
	private String longName;
    @Column(name = "ListingDate")
    @Temporal(TemporalType.DATE)
    private Date listingDate;
	@Protobuf
	private long listingDateL;
    @Column(name = "FaceValue")
    @Protobuf
	private Integer faceValue;
    @Column(name = "TradeUnit")
    @Protobuf
	private Integer tradeUnit;
    @Column(name = "Currency")
    @Protobuf
	private String currency;
    @Column(name = "ContractSize")
    @Protobuf
	private Integer contractSize;
    @Column(name = "TradeType")
    @Protobuf
	private String tradeType;
    @Column(name = "ClearType")
    @Protobuf
	private String clearType;
    @Column(name = "ContractMonth")
    @Protobuf
	private String contractMonth;
    @Column(name = "ExpirationDate")
    @Temporal(TemporalType.DATE)
    private Date expirationDate;
	@Protobuf
	private long expirationDateL;
    @Column(name = "UnderlyingCode")
    @Protobuf
	private String underlyingCode;
    @Column(name = "Underlyingobj")
    @Protobuf
	private String underlyingobj;
    @Column(name = "First")
    @Protobuf
	private String first;
    @Column(name = "Secend")
    @Protobuf
	private String secend;
    @Column(name = "Third")
    @Protobuf
	private String third;
    @Column(name = "PutCall")
    @Protobuf
	private String putCall;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "StrikePrice")
    @Protobuf
	private Float strikePrice;
    @Column(name = "OptionRate")
    @Protobuf
	private Float optionRate;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public TraceObjInfo() {
    }

    public TraceObjInfo(Integer sid) {
        this.sid = sid;
    }

    public TraceObjInfo(Integer sid, String traceType, String objID, String regionID, String obj, String marketCode, String classCode, String name, String eName) {
        this.sid = sid;
        this.traceType = traceType;
        this.objID = objID;
        this.regionID = regionID;
        this.obj = obj;
        this.marketCode = marketCode;
        this.classCode = classCode;
        this.name = name;
		this.nameBit = CodeTool.StringToBit(name);
        this.eName = eName;
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getTraceType() {
        return traceType;
    }

    public void setTraceType(String traceType) {
        this.traceType = traceType;
    }

    public String getObjID() {
        return objID;
    }

    public void setObjID(String objID) {
        this.objID = objID;
    }

    public String getRegionID() {
        return regionID;
    }

    public void setRegionID(String regionID) {
        this.regionID = regionID;
    }

    public String getObj() {
        return obj;
    }

    public void setObj(String obj) {
        this.obj = obj;
    }

    public String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        this.marketCode = marketCode;
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        this.setNameBit(CodeTool.StringToBit(name));
    }

    public String getEName() {
        return geteName();
    }

    public void setEName(String eName) {
        this.seteName(eName);
    }

    public String getLongName() {
        return longName;
    }

    public void setLongName(String longName) {
        this.longName = longName;
    }

    public Date getListingDate() {
        return listingDate;
    }

    public void setListingDate(Date listingDate) {
        this.listingDate = listingDate;
		this.setListingDateL(CodeTool.DateToLong(listingDate));
    }

    public Integer getFaceValue() {
        return faceValue;
    }

    public void setFaceValue(Integer faceValue) {
        this.faceValue = faceValue;
    }

    public Integer getTradeUnit() {
        return tradeUnit;
    }

    public void setTradeUnit(Integer tradeUnit) {
        this.tradeUnit = tradeUnit;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public Integer getContractSize() {
        return contractSize;
    }

    public void setContractSize(Integer contractSize) {
        this.contractSize = contractSize;
    }

    public String getTradeType() {
        return tradeType;
    }

    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }

    public String getClearType() {
        return clearType;
    }

    public void setClearType(String clearType) {
        this.clearType = clearType;
    }

    public String getContractMonth() {
        return contractMonth;
    }

    public void setContractMonth(String contractMonth) {
        this.contractMonth = contractMonth;
    }

    public Date getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
		this.setExpirationDateL(CodeTool.DateToLong(expirationDate));
    }

    public String getUnderlyingCode() {
        return underlyingCode;
    }

    public void setUnderlyingCode(String underlyingCode) {
        this.underlyingCode = underlyingCode;
    }

    public String getUnderlyingobj() {
        return underlyingobj;
    }

    public void setUnderlyingobj(String underlyingobj) {
        this.underlyingobj = underlyingobj;
    }

    public String getFirst() {
        return first;
    }

    public void setFirst(String first) {
        this.first = first;
    }

    public String getSecend() {
        return secend;
    }

    public void setSecend(String secend) {
        this.secend = secend;
    }

    public String getThird() {
        return third;
    }

    public void setThird(String third) {
        this.third = third;
    }

    public String getPutCall() {
        return putCall;
    }

    public void setPutCall(String putCall) {
        this.putCall = putCall;
    }

    public Float getStrikePrice() {
        return strikePrice;
    }

    public void setStrikePrice(Float strikePrice) {
        this.strikePrice = strikePrice;
    }

    public Float getOptionRate() {
        return optionRate;
    }

    public void setOptionRate(Float optionRate) {
        this.optionRate = optionRate;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraceObjInfo)) {
            return false;
        }
        TraceObjInfo other = (TraceObjInfo) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.trace.TraceObjInfo[ sid=" + sid + " ]";
    }

    public byte[] getNameBit() {
        return nameBit;
    }

    public void setNameBit(byte[] nameBit) {
        this.nameBit = nameBit;
		this.name = CodeTool.BitToString(nameBit);
    }

    public String geteName() {
        return eName;
    }

    public void seteName(String eName) {
        this.eName = eName;
    }

    public long getListingDateL() {
        return listingDateL;
    }

    public void setListingDateL(long listingDateL) {
        this.listingDateL = listingDateL;
		this.listingDate = CodeTool.LongToDate(listingDateL);
    }

    public long getExpirationDateL() {
        return expirationDateL;
    }

    public void setExpirationDateL(long expirationDateL) {
        this.expirationDateL = expirationDateL;
		this.expirationDate = CodeTool.LongToDate(expirationDateL);
    }
    
}
